package com.wmeimob.fastboot.jiubei.config;

import com.wmeimob.fastboot.jiubei.entity.Member;
import com.wmeimob.fastboot.starter.security.interfaces.JsonWebTokenEncoder;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Meimeng
 */
public class UserInfoJsonWebTokenEncoder implements JsonWebTokenEncoder {

    @Override
    public Map<String, Object> encode(UserDetails userDetails) {

        Member member = (Member) userDetails;
        Map<String, Object> claims = new HashMap<>(5);
        claims.put("id", member.getId());
        claims.put("nickname", member.getNickname());
        claims.put("phone", member.getPhone());
        claims.put("headImg", member.getHeadImg());
        claims.put("vipNo", member.getVipNo());
        return claims;
    }
}
